import request from '@/utils/service.js'
//菜品类别
export let selectone=(foodName)=>{
    return request({
        url:' /sort/selectone',
        method:'GET',
        params:{
            sortName:foodName
        }
    })
}
//菜品列表
export let findAllsort=(current,pageSize)=>{
    if(!current) current=1
    if(!pageSize) pageSize=10
    return request({
        url:'/food/findAllsort',
        method:'GET',
        params:{
            current,
            pageSize
        }
    })
}
// //菜品编辑修改
// export let updateOne=()=>{
//     return request({
//         url:' /food/updateOne',
//         method:'POST',
//         params:{
//             current:1,
//             pageSize:10
//         }
//     })
// }

//新增一个菜品类别
export let insertSort=(mingcheng,beizhu)=>{
    return request({
        url:'/sort/insertSort',
        method:'POST',
        data:{
            sortName: mingcheng,
            sortNote: beizhu,
            
        }
    })
}
//删除一个菜品类别
export let deleteOne=(id)=>{
    return request({
        url:'  /sort/deleteOne',
        method:'GET',
        params:{
            sortId:id
        }
    })
}


//根据类别分页查询所有菜品
export let findbylimitAndsort=(current,pageSize)=>{
    if(!current) current=1
    if(!pageSize) pageSize=10000000
    return request({
        url:'/food/findbylimitAndsort',
        method:'GET',
        params:{ 
            current,
            pageSize
        }
    })
}

//菜品档案渲染
export let findAllFoodByLimit=()=>{
    return request({
        url:'/food/findAllFoodByLimit',
        method:'GET',
        params:{
            flag:1,
            current:1,
            pageSize:200000,
         }
    })
}


//上传菜品图片
export let uploadimg=(tupian)=>{
    return request({
        url:' /food/uploadimg',
        method:'POST',
        data:{
            body: {
                foodPic: tupian,
            }
            
        }
    })
}


// 根据菜品名称模糊搜索
export let findByLike=(foodName)=>{
    return request({
        url:' /food/findByLike',
        method:'GET',
        params:{
            foodName,
         }
    })
}

//菜品档案新增
export let addonefood=(mingcheng,imageUrl,danjia,kucun,leibie)=>{
    return request({
        url:' /food/addonefood',
        method:'POST',
        data:{
            
                foodName:mingcheng,
                foodPic:imageUrl,
                foodMoney:danjia,
                foodNum:kucun,
                sortId:leibie
            
            
        }
    })
}